<template>
  <div class="app-container">
    <el-table
      :data="list"
      style="width: 100%"
      row-key="id"
      border
      lazy
      :load="load"
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
    >
      <el-table-column
        prop="name"
        label="名称"
        width="150"
      />
      <el-table-column
        prop="dictCode"
        label="编码"
        width="150"
      />
      <el-table-column
        prop="value"
        label="值"
        width="150"
      />
      <el-table-column
        prop="createTime"
        label="创建时间"
      />
    </el-table>
  </div>
</template>
<script>
import dict from '@/api/dict.js'
export default {
  data() {
    return {
      list: [] // 数据字典列表数组
    }
  },
  created() {
    this.getDictList(1)
  },
  methods: {
    // 数据字典列表
    getDictList(id) {
      dict.dictList(id)
        .then(response => {
          this.list = response.data.items
        })
    },
    load(tree, treeNode, resolve) {
      dict.dictList(tree.id).then(response => {
        resolve(response.data.items)
      })
    }
  }
}
</script>
